import os

count = 0

def list_files(dir_path):
    global count
    """
    列出指定文件夹下的所有文件和子文件夹。
    """
    for root, dirs, files in os.walk(dir_path):
        level = root.replace(dir_path, '').count(os.sep)
        indent = ' ' * 4 * (level)
        # print('{}{}/'.format(indent, os.path.basename(root)))
        subindent = ' ' * 4 * (level + 1)

        for fileName in files:
            # print(root + '/' + fileName)
            if fileName.endswith('.java'):
                # print('{}{}'.format(subindent, fileName))
                with open(root + '/' + fileName, 'r', encoding='utf-8') as file:
                    for line in file:
                        if '@PostMapping(' in line.strip():
                            count += 1

# list_files('D:/project/SCMP/scmp-coding231019/trunk')
# 总(包括feign接口)：1792
list_files('D:/project/SCMP/scmp-coding231019/trunk/scmp-manage-parent')
# manage：689
list_files('D:/project/SCMP/scmp-coding231019/trunk/scmp-provider-parent')
# provider：115
list_files('D:/project/SCMP/scmp-coding231019/trunk/scmp-charging-rt-parent')
# provider：7
print(count)